{% extends "base_ubi8.j2" %}
{% block SETUP_BENTO_BASE_IMAGE %}
{% set short_pyver = __options__python_version.split('.') | join('') %}
{% set ubi_home_root="/opt/app-root/src" %}
{% set app_root="/opt/app-root" %}
{% set path_root="/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" %}
{{ super() }}

# Since cuda is built on top of ubi8/ubi, it doesn't have the correct python
# repository provided by RHEL, so we need to setup some ENV variables according
# to s2i-base image.
# Refer to https://github.com/sclorg/s2i-base-container/blob/master/core/Dockerfile.rhel8
ENV \
  HOME={{ ubi_home_root }} \
  APP_ROOT={{ app_root }} \
  PATH={{ path_root }}

{% call common.RUN(__enable_buildkit__) -%} {{ common.mount_cache("/var/cache/yum") }} {% endcall -%} set -eux && \
    dnf install -y --setopt=tsflags=nodocs python{{ short_pyver }} && \
    ln -sf /usr/bin/python{{ __options__python_version }} /usr/bin/python3 && \
    ln -sf /usr/bin/pip{{ __options__python_version }} /usr/bin/pip3

RUN python3 --version

{% endblock %}
{% block SETUP_BENTO_ENTRYPOINT %}
RUN rm -rf /var/cache/yum
{{ super() }}
{% endblock %}
